abstract class Animal {
    String name;
    String callvoice;

    abstract void cry();
    abstract String getAnimalName(String n);

    public void setAnimalName(String n) {
        this.name = n;
    }
}

class Simulator{
    public void playSound(Animal animal){
        animal.cry();
    }
}

class Dog extends Animal {
    
    
    void cry() {
        System.out.println("wang !"); // 实现叫声方法
    }

    
    String getAnimalName(String n) {
        this.name = n; 
        return this.name; 
    }
}

class Cat extends Animal {
    
    
    void cry() {
        System.out.println("miao~!"); 
    }

    
    String getAnimalName(String n) {
        this.name = n; 
        return this.name; 
    }
}

public class Application {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.getAnimalName("Dog");

        Cat cat = new Cat();
        cat.getAnimalName("Cat");

        Simulator simulator = new Simulator(); 

        // 使用模拟器播放声音
        System.out.println(dog.getAnimalName("Dog") + " 的声音是：");
        simulator.playSound(dog); // 播放狗的叫声

        System.out.println(cat.getAnimalName("Cat") + " 的声音是：");
        simulator.playSound(cat); // 播放猫的叫声
    }
}

